package com.regex.web.controller.appoint;

import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.regex.web.base.BaseController;
import com.regex.web.service.essentialinformation.IClDisabledInfoService;
import com.regex.web.service.jay.IClJyDxsxzfService;
import com.regex.web.vo.ResultVO;

@RestController
@CrossOrigin
public class InformationRestSummaryController extends BaseController{

	@Autowired
	private IClDisabledInfoService IClDisabledInfoService;
	
	@Autowired
	private IClJyDxsxzfService IClJyDxsxzfService;

	@RequestMapping("getdjandlx")
	@ResponseBody
	public ResultVO<List<Map>>  getdjandlx(){
		List<Map> map=IClDisabledInfoService.getdjandlx();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	@RequestMapping("getshfshlx")
	@ResponseBody
	public ResultVO<List<Map>>  getshfshlx(){
		List<Map> map=IClDisabledInfoService.getshfshlx();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	@RequestMapping("getsffsh")
	@ResponseBody
	public ResultVO<Map<String, Object>>  getsffsh(){
		Map<String, Object> map=IClDisabledInfoService.getsffsh();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	@RequestMapping("getqysl")
	@ResponseBody
	public ResultVO<List<Map>>  getqysl(){
		List<Map> map=IClDisabledInfoService.getqysl();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}


	
	@RequestMapping("getwhcd")
	@ResponseBody
	public ResultVO<List<Map>>  getwhcd(){
		List<Map> map=IClDisabledInfoService.getwhcd();
		
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	@RequestMapping("gethyzk")
	@ResponseBody
	public ResultVO<List<Map>>  gethyzk(){
		List<Map> map=IClDisabledInfoService.gethyzk();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	@RequestMapping("getsex")
	@ResponseBody
	public ResultVO<List<Map>>   getsex(){
		List<Map> map=IClDisabledInfoService.getsex();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	@RequestMapping("getcsrq")
	@ResponseBody
	public ResultVO<List<Map>>   getcsrq(){
		List<Map> map=IClDisabledInfoService.getcsrq();
		 Calendar cal = Calendar.getInstance();
	        int year = cal.get(Calendar.YEAR);
	        int a=0,b=0,c=0,d=0,e=0,f=0,g=0;
		for (Map map2 : map) {
			String nf=map2.get("BIRTHDAY").toString().substring(0,4);
		 int nl=year -	Integer.parseInt(nf);
		 if(0 < nl && nl <=16){
			 map2.remove("BIRTHDAY");
			 a=a+1;
		 }
		 if(16 < nl && nl <=30){
			 map2.remove("BIRTHDAY");
			b=b+1;
		 }
		 if(30 < nl && nl <=45){
			 map2.remove("BIRTHDAY");
			c=c+1;
		 }
		 if(45 < nl && nl <=60){
			 map2.remove("BIRTHDAY");
			 d=d+1;
		 }
		 if(60 < nl && nl <=75){
			 map2.remove("BIRTHDAY");
			e=e+1;
		 }
		 if(75 < nl && nl <=90){
			 map2.remove("BIRTHDAY");
			f=f+1;
		 }
		 if(90 < nl ){
			 map2.remove("BIRTHDAY");
			g=g+1;
		 }
	
		}
		map.clear();
		Map<String, Object> maps=new HashMap();
		 maps.put("name", "0-16");
		 maps.put("value", a);
		 map.add(maps);
		 Map<String, Object> map2=new HashMap();
		 map2.put("name", "16-30");
		 map2.put("value", b);
		 map.add(map2);
		 Map<String, Object> map3=new HashMap();
		 map3.put("name", "30-45");
		 map3.put("value", c);
		 map.add(map3);
		 Map<String, Object> map4=new HashMap();
		 map4.put("name", "45-60");
		 map4.put("value", d);
		 map.add(map4);
		 Map<String, Object> map5=new HashMap();
		 map5.put("name", "60-75");
		 map5.put("value", e);
		 map.add(map5);
		 Map<String, Object> map6=new HashMap();
		 map6.put("name", "75-90");
		 map6.put("value", f);
		 map.add(map6);
		 Map<String, Object> map7=new HashMap();
		 map7.put("name", "90以上");
		 map7.put("value", g);
		map.add(map7);
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	
	@RequestMapping("getbtlx")
	@ResponseBody
	public ResultVO<List<Map>>   getbtlx(){
		List<Map> map=IClDisabledInfoService.getbtlx();
		return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
		
	}
	/**
	 * 教育
	 */
		@RequestMapping("getDxsxzsdjolx")
		@ResponseBody
		public ResultVO<List<Map>>  getDxsxzsdjolx(){
			List<Map> map=IClJyDxsxzfService.getDxsxzsdjolx();
			return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
			
		}
		
		@RequestMapping("getDxsxzslx")
		@ResponseBody
		public ResultVO<List<Map>>  getDxsxzslx(){
			List<Map> map=IClJyDxsxzfService.getDxsxzslx();
			return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
			
		}
		
		@RequestMapping("getDxsxzsdj")
		@ResponseBody
		public ResultVO<List<Map>>  getDxsxzsdj(){
			List<Map> map=IClJyDxsxzfService.getDxsxzsdj();
			return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
			
		}
	
		@RequestMapping("getDxsxzsxb")
		@ResponseBody
		public ResultVO<List<Map>>  getDxsxzsxb(){
			List<Map> map=IClJyDxsxzfService.getDxsxzsxb();
			return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
			
		}
		
		@RequestMapping("getDxsxzswhcd")
		@ResponseBody
		public ResultVO<List<Map>>  getDxsxzswhcd(){
			List<Map> map=IClJyDxsxzfService.getDxsxzswhcd();
			return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
			
		}
		
		@RequestMapping("getEtbjfXbLx")
		@ResponseBody
		public ResultVO<List<Map>>  getEtbjfXbLx(){
			List<Map> map=IClJyDxsxzfService.getEtbjfXbLx();
			return  ResultVO.success(map, ResultVO.SUCCESS, ResultVO.errors.get(ResultVO.SUCCESS));
			
		}
}